package com.example.cas;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @auther zzyy
 * @create 2021-03-17 15:13
 */
@Slf4j
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        log.info("ret:{}", atomicInteger.get());
        log.info("ret:{},{}", atomicInteger.compareAndSet(5, 308), atomicInteger.get());
        log.info("ret:{},{}", atomicInteger.compareAndSet(5, 3333), atomicInteger.get());

    }
}
